import request from "./request.js";

//角色列表 添加

async function setRoles(parems) {
    let res = await request({
        url: 'roles',
        method: 'post',
        data: parems
    })
    return res
}

// 修改 角色 接口
async function seteditRoles(parems) {
    let res = await request({
        url: `roles/${parems.id}`,
        method: 'put',
        data: {
            roleName: parems.roleName,
            roleDesc: parems.roleDesc
        }
    })
    return res
}

// 删除接口

async function deleteRoles(parems) {
    let res = await request({
        url: `roles/${parems.id}`,
        method: 'delete',
    })
    return res
}

// 获取权限列表成功

async function getPowerlist() {
    let res = await request({
        url: 'rights/tree',
        method: 'get',
    })
    return res
}

// 橘色授权

async function setPoweruser(parems) {
    console.log(parems);
    let res = await request({
        url: `roles/${parems.roleId}/rights`,
        method: 'post',
        data: {
            rids: parems.rids
        }
    })
    return res
}
// 删除 指定 的
async function deletePoweruser(parems) {
    console.log(parems);
    let res = await request({
        url: `roles/${parems.roleId}/rights/${parems.rightId}`,
        method: 'delete',
    })
    return res
}

//权限 列表 数据

async function getRights() {
    let res = await request({
        url: 'rights/list',
        method: 'get',
    })
    return res
}


export { setRoles, seteditRoles, deleteRoles, getPowerlist, setPoweruser, deletePoweruser, getRights }